#include <QFileDialog>

#include "downloadpdb.h"

using namespace PBVP;

DownloadPDBDialog::DownloadPDBDialog(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	m_pParent = parent;
	connect(ui.savePDBButton, SIGNAL(pressed()), this, SLOT(changePath()));
	connect(ui.PDBNameEdit, SIGNAL(textChanged(const QString&)), 
		this, SLOT(setPathEditText(const QString&)));
}

DownloadPDBDialog::~DownloadPDBDialog()
{
}

//////////////////////////////////////////////////////////////////////////
// slots
//////////////////////////////////////////////////////////////////////////
void DownloadPDBDialog::changePath()
{
	QString path = QFileDialog::getSaveFileName(m_pParent, "Save Path", 
		"", "PDF file(*.pdb);;");
	if (path.isNull()) return;
	ui.savePDBEdit->setText(path);
}

void DownloadPDBDialog::setPathEditText(const QString &name)
{
	QString str(name);
	ui.savePDBEdit->setText(str.append(".pdb"));
}